//
//  HomePageViewController.m
//  YiqiMobile
//
//  Created by henry on 13-3-23.
//  Copyright (c) 2013年 henry. All rights reserved.
//


#import "HomePageViewController.h"
#import "UIView+Origami.h"
#import "Utility.h"
#import "Config.h"
#import "HomePageViewCell.h"
#import "TogetherSecondViewController.h"
#import "HomePageSecondViewController.h"
#import "SearchViewController.h"
#import "BwhcViewController.h"
#import "AppDelegate.h"
#import "CreateQuanziView.h"
#import "CustomNavigationController.h"
#import "MoreQuanziViewController.h"
#import "SettingViewController.h"
#import "DefineAction.h"
#import "MemberSecondViewController.h"
#import "JSON.h"
#import "MBProgressHUD.h"
#import "BowenPreviewViewController.h"
  static NSString *CellIdentifier = @"homePageViewCell";

@interface HomePageViewController (){
    BOOL currDirection;
    int foldsNum;
    float durationNum;
}
 -(void) initPushMenu;
-(void) loadPushDataFromServer;//推拉菜单
-(void) loadbowenListFromServer;//博文列表
@end

@implementation HomePageViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    self.view.backgroundColor=[UIColor whiteColor];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad{
    [super viewDidLoad];
    self.isFirst=YES;
     self.buttonIndex=0;
     self.navigationItem.titleView=[Utility getTitleView:@"首页"];
     self.isShowLevelPop=true;
    float height=367-38;
    if (iPhone5) {
        height+=88;
    }
    CGRect tableViewFrame=CGRectMake(0, self.bowenButton.frame.size.height, UISCREEN_WIDTH, height);
    self.mytableView=[[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStylePlain];
     self.mytableView.tag=HOMEPAGETABLEVIEWTAG;
    //self.mytableView.showsVerticalScrollIndicator=NO;
     self.mytableView.separatorStyle=UITableViewCellEditingStyleNone;
    self.mytableView.delegate=self;
    self.mytableView.dataSource=self;
    [self.view addSubview:self.mytableView];
    
    self.arraybwList=[NSMutableArray array];
    self.arrayggList=[NSMutableArray array];
    
    self.arrayPushList=[NSMutableArray array];
    //导航栏左边按钮
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:[Utility customButton:self action:@selector(onClickAction:) normalImage:@"pushButton_normal.png" lightedImage:@"pushButton_hover.png" frame:CGRectMake(0, 0, 35, 35) title:nil tag:PUSHMENUBUTTONTAG]];
    //导航栏右边按钮
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithCustomView:[Utility customButton:self action:@selector(onClickAction:) normalImage:@"moreButton_normal.png" lightedImage:@"moreButton_hover.png" frame:CGRectMake(0, 0, 35, 35) title:nil tag:PUSHMENUBUTTONTAG+1]];
    
    //推拉菜单
    [self initPushMenu];
    
    
    
   
        _refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.mytableView.bounds.size.height, self.view.frame.size.width, self.mytableView.bounds.size.height)];
        _refreshHeaderView.delegate = self;
        [self.mytableView addSubview:_refreshHeaderView];
    [_refreshHeaderView refreshLastUpdatedDate];
}



-(void) loadPushDataFromServer{
   /* AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
    if (app.status==NotReachable) {
        [Utility customAlertWithMsg:NETWORTERROE andTitle:ALRRTTITLE andDelagate:nil];
        return;
    }*/
    

    [[MBProgressHUD showHUDAddedTo:self.tabBarController.view  animated:NO] setDetailsLabelText:LOADING_TITLE_DEFAULT];
     NSString *userId=[[NSUserDefaults standardUserDefaults] objectForKey:USERID];
    NSString *url=[NSString stringWithFormat:@"%@/%@?id=%@&u.u0=%@",[Utility getServerUrl],PUSHMEMULISTACTION,userId,userId];
   
    self.request=[[URLRequest alloc] initWithPostURL:url andDelegate:self andPostData:nil andFile:nil];
    [self.request startLoadData];
}


-(void) loadbowenListFromServer{
    [[MBProgressHUD showHUDAddedTo:self.tabBarController.view  animated:NO] setDetailsLabelText:LOADING_TITLE_DEFAULT];
    NSString *userId=[[NSUserDefaults standardUserDefaults] objectForKey:USERID];
    NSString *url=[NSString stringWithFormat:@"%@/%@?id=%@&type=1",[Utility getServerUrl],ALLBOWENBYU,userId];
    
    self.request=[[URLRequest alloc] initWithPostURL:url andDelegate:self andPostData:nil andFile:nil];
    [self.request startLoadData];
}

-(void) loadgonggaoListFromServer{
    [[MBProgressHUD showHUDAddedTo:self.tabBarController.view  animated:NO] setDetailsLabelText:LOADING_TITLE_DEFAULT];
    NSString *url=[NSString stringWithFormat:@"%@/%@",[Utility getServerUrl],GONGGAOLIST];
    
    self.request=[[URLRequest alloc] initWithPostURL:url andDelegate:self andPostData:nil andFile:nil];
    [self.request startLoadData];
}

- (void)requestFinished:(id)context{
    [MBProgressHUD hideAllHUDsForView:self.tabBarController.view  animated:NO];
    @try{
        NSDictionary *result=[context JSONValue];
        if (result!=nil&&[[result objectForKey:@"code"] integerValue]==0) {
            if ([[result  objectForKey:@"method"] isEqual:PUSHMEMULISTACTION]) {
                [self loadbowenListFromServer];
                 [self.pushMenuView.options removeAllObjects];
                NSArray *canyuList=[[result objectForKey:@"data"] objectForKey:@"nrList"];
                if (canyuList&&canyuList.count>0) {
                     [self.pushMenuView.options addObject:@{@"sectionImage":@"pushmenu_section0.png",@"list":canyuList}];
                }
                NSArray *gaunzhuList=[[result objectForKey:@"data"] objectForKey:@"nrList1"];
                if (gaunzhuList&&gaunzhuList.count>0) {
                    [self.pushMenuView.options addObject:@{@"sectionImage":@"pushmenu_section1.png",@"list":gaunzhuList}];
                }
                [self.pushMenuView.tableView reloadData];
                
            }else if ([[result objectForKey:@"method"] isEqual:ALLBOWENBYU]) {
                [self.arraybwList removeAllObjects];
                NSArray *list=[result  objectForKey:@"list"];
                if (list&&list.count>0) {
                    [self.arraybwList addObjectsFromArray:list];
                    [self.mytableView reloadData];
                }

            }else if ([[result objectForKey:@"method"] isEqual:GONGGAOLIST]){
                [self.arrayggList removeAllObjects];
                NSArray *list=[result  objectForKey:@"list"];
                if (list&&list.count>0) {
                    [self.arrayggList addObjectsFromArray:list];
                    [self.mytableView reloadData];
                }

            }
        }else{
            [Utility customAlertWithMsg:PROCESSERROE andTitle:ALRRTTITLE andDelagate:nil];
        }
    }@catch (NSException *e) {
        [Utility customAlertWithMsg:NETWORTERROE andTitle:ALRRTTITLE andDelagate:nil];
    }
     [self doneLoadingTableViewData];
}

- (void)requestFailed:(id)context error:(NSString *)error{
    [Utility customAlertWithMsg:NETWORTERROE andTitle:ALRRTTITLE andDelagate:nil];
}



- (IBAction)onclickSubMenu:(id)sender{//顶部切换菜单
    UIButton *selectButton=(UIButton*)sender;
    if (selectButton==self.bowenButton) {
        self.buttonIndex=0;
        self.bowenButton.selected=YES;
        self.gonggaoButton.selected=NO;
        [self loadbowenListFromServer];
    }else{
        self.buttonIndex=1;
        self.bowenButton.selected=NO;
        self.gonggaoButton.selected=YES;
        [self loadgonggaoListFromServer];
    }
}

-(IBAction)onClickAction:(id)sender{//导航顶部按钮
    UIButton *button=(UIButton*)sender;
    switch (button.tag) {
        case PUSHMENUBUTTONTAG:{//打开关闭推拉菜单
            if (self.isShowStatus) {
                [self swipeLeft:nil];
            }else{
                [self swipeRight:nil];
            }
            break;
        }
        case PUSHMENUBUTTONTAG+1:{//更多菜单
            [self popLevelAction:nil];
            break;
        }
        default:
            break;
    }
}


-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
    self.hidesBottomBarWhenPushed=NO;
    [app.tabBarController hideExistingTabBar];
    app.tabBarController.tabBarView.hidden=NO;
    HomePageViewController *homePageViewController=(HomePageViewController*)[[[self.tabBarController.viewControllers objectAtIndex:0] viewControllers] objectAtIndex:0];
    homePageViewController.isShowLevelPop=YES;
    UIView *rightPopView=[self.view  viewWithTag:HOMEPAGELPV];
    [rightPopView removeFromSuperview];
    if (self.isFirst) {
         [self loadPushDataFromServer];
          self.isFirst=NO;
    }
    
}




//表视图委托
#pragma mark -
#pragma mark table view data source methods

//返回某个表视图有多少行数据
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ( self.buttonIndex==0) {
        return [self.arraybwList count];
    }else{
         return [self.arrayggList count];
    }
    
}
//设置行高度
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 61;
}


//表视图显示表视图项时调用：第一次显示（根据视图大小显示多少个视图项就调用多少次）以及拖动时调用
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HomePageViewCell *cell =(HomePageViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[HomePageViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                       reuseIdentifier: CellIdentifier];
    }
    NSString *content=nil;
    NSString *detalText=nil;
    NSString *dateText=nil;
    if ( self.buttonIndex==0) {
      NSDictionary *dict=[self.arraybwList objectAtIndex:indexPath.row];
        content=[dict objectForKey:@"str2"];
        detalText=[NSString stringWithFormat:@"圈子: %@  阅读: %@  评论: %@  收藏: %@ ",[dict objectForKey:@"str10"],[dict objectForKey:@"count3"],[dict objectForKey:@"count5"],[dict objectForKey:@"count6"]];
        [NSString stringWithFormat:@"%@",[Utility datefromSeconds:[dict objectForKey:@"dat4"] andDateFormat:@"yyyy/MM/dd"]];
    }else{
        NSDictionary *dict=[self.arrayggList objectAtIndex:indexPath.row];
        content=[dict objectForKey:@"gg1"];
        dateText=@"";
    }
    cell.content.text=content;
    cell.detailTitle1.text=detalText;
    
    cell.detailTitle2.text=dateText;
    return cell;
}

//数据源委托
#pragma mark -
#pragma mark table delegate methods


//某行已经被选中时调用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
    if (self.buttonIndex==0) {
         BowenPreviewViewController *bowen=[[BowenPreviewViewController alloc] initWithNibName:nil bundle:nil];
         NSDictionary *dcit=[self.arraybwList objectAtIndex:indexPath.row];
         [bowen loadDataFromServer:[dcit objectForKey:@"str1"]];
         [self.navigationController pushViewController:bowen animated:YES];
    }else{
        [Utility customAlertWithMsg:@"还没有接口和ui页面" andTitle:@"提醒" andDelagate:nil];
    }
   
    
        
}




//初始push菜单
-(void) initPushMenu{
    foldsNum=1;
    durationNum=0.5f;
    currDirection = XYOrigamiDirectionFromLeft;
    self.isShowStatus=false;
    CGRect rect=[[UIScreen mainScreen] bounds];
    rect.size.width=225.0f;
    self.pushMenuView=[[PushMenuView alloc] initWithFrame:rect];
    self.pushMenuView.delegate=self;
    [self.pushMenuView showInView:self.tabBarController.view animated:YES];
     UISwipeGestureRecognizer* recognizerRight;
     // handleSwipeFrom 是偵測到手势，所要呼叫的方法
     recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
     // 不同的 Recognizer 有不同的实体变数
     // 例如 SwipeGesture 可以指定方向
     // 而 TapGesture 則可以指定次數
     recognizerRight.direction = UISwipeGestureRecognizerDirectionRight;
     [self.view addGestureRecognizer:recognizerRight];
     
     UISwipeGestureRecognizer* recognizerLeft;
     // handleSwipeFrom 是偵測到手势，所要呼叫的方法
     recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft:)];
     // 不同的 Recognizer 有不同的实体变数
     // 例如 SwipeGesture 可以指定方向
     // 而 TapGesture 則可以指定次數
     recognizerLeft.direction = UISwipeGestureRecognizerDirectionLeft;
     [self.view addGestureRecognizer:recognizerLeft];
    
}

//响应push菜单中的新建和更多按钮
-(void)onclickPushbutton:(int) tag{
    
    switch (tag) {
        case 0:{
            //更多
            [self swipeLeft:nil];
            CustomNavigationController *navigationController=(CustomNavigationController*)[self.tabBarController.viewControllers objectAtIndex:self.tabBarController.selectedIndex];
            MoreQuanziViewController *moreQuanziViewController=[[MoreQuanziViewController alloc] initWithNibName:nil bundle:nil];
            AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
            moreQuanziViewController.hidesBottomBarWhenPushed=YES;
            app.tabBarController.tabBarView.hidden=YES;
            [app.tabBarController  hideExistingTabBar];
            [navigationController pushViewController:moreQuanziViewController animated:YES];
            [moreQuanziViewController loadDataFromServer:1];
            break;
        }
        case 1:{
            CGRect rect=CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT);
            CreateQuanziView *createQuanziView=[[CreateQuanziView alloc] initWithFrame:rect];
            AppDelegate *appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
            [appDelegate.window addSubview:createQuanziView];
            
            break;
        }
        default:
            break;
    }
    
}

//点击下面tag 
-(void) showdataForClicktag:(NSString *)anindex  andParam:(NSDictionary *)param{
    [self leveyPopListView:nil didSelectedIndex:[anindex integerValue] andParam:param];
}
#pragma -mark pushmenu delagate
- (void)leveyPopListView:(PushMenuView *)popListView didSelectedIndex:(NSInteger)anIndex andParam:(NSDictionary *)param{
    CustomNavigationController *navigationController=(CustomNavigationController*)[self.tabBarController.viewControllers objectAtIndex:self.tabBarController.selectedIndex];
    [self swipeLeft:nil];
    if (anIndex==-1||param==nil) {
        [navigationController  popToRootViewControllerAnimated:YES];
    }else{
        if (self.tabBarController.selectedIndex==0) {
            for (UIViewController *viewController in navigationController.viewControllers) {
                if ([viewController isKindOfClass:([HomePageSecondViewController class])]) {
                    if ([viewController respondsToSelector:@selector(loadData:)]) {
                        [viewController performSelector:@selector(loadData:) withObject:param];
                    }
                    [navigationController popToViewController:viewController animated:YES];
                    return;
                }
            }
            HomePageSecondViewController *homePageSecondViewController=[[HomePageSecondViewController alloc] initWithNibName:nil bundle:nil];
            [homePageSecondViewController performSelector:@selector(loadData:) withObject:param];
            [navigationController  pushViewController:homePageSecondViewController animated:YES];
        }else if(self.tabBarController.selectedIndex==1){
            for (UIViewController *viewController in navigationController.viewControllers) {
                if ([viewController isKindOfClass:([TogetherSecondViewController class])]) {
                    if ([viewController respondsToSelector:@selector(loadData:)]) {
                        [viewController performSelector:@selector(loadData:) withObject:param];
                     }
                     [navigationController popToViewController:viewController animated:YES];
                    return;
                 }
              }
            TogetherSecondViewController *togetherSecondViewController=[[TogetherSecondViewController alloc] initWithNibName:nil bundle:nil];
            [togetherSecondViewController loadData:param];
            [navigationController pushViewController:togetherSecondViewController animated:YES];
        }else if(self.tabBarController.selectedIndex==2){
            for (UIViewController *viewController in navigationController.viewControllers) {
                if ([viewController isKindOfClass:([MemberSecondViewController class])]) {
                    if ([viewController respondsToSelector:@selector(loadData:)]) {
                        [viewController performSelector:@selector(loadData:) withObject:param];
                    }
                    [navigationController popToViewController:viewController animated:YES];
                    return;
                }
            }
            MemberSecondViewController *memberSecondViewController=[[MemberSecondViewController alloc] initWithNibName:nil bundle:nil];
            [memberSecondViewController loadData:param];
            [navigationController pushViewController:memberSecondViewController animated:YES];
        }

    }
   
}
//取消push菜单
- (void)leveyPopListViewDidCancel{

}


#pragma -mark swipe
//关闭push菜单
- (IBAction)swipeLeft:(id)sender {
    if (currDirection == XYOrigamiDirectionFromLeft) {
        [self.tabBarController.view  hideOrigamiTransitionWith:self.pushMenuView
                                       NumberOfFolds:foldsNum
                                            Duration:durationNum
                                           Direction:XYOrigamiDirectionFromLeft
                                          completion:^(BOOL finished) {
                                              self.isShowStatus=false;
                                          }];
    }
    else {
        [self.tabBarController.view showOrigamiTransitionWith:self.pushMenuView
                                       NumberOfFolds:foldsNum
                                            Duration:durationNum
                                           Direction:XYOrigamiDirectionFromRight
                                          completion:^(BOOL finished) {
                                              self.isShowStatus=true;
                                          }];
    }
}
//打开push菜单
- (IBAction)swipeRight:(id)sender {
    if (currDirection == XYOrigamiDirectionFromLeft) {
        [self.tabBarController.view  showOrigamiTransitionWith:self.pushMenuView
                                       NumberOfFolds:foldsNum
                                            Duration:durationNum
                                           Direction:XYOrigamiDirectionFromLeft
                                          completion:^(BOOL finished) {
                                              self.isShowStatus=true;
                                              
                                          }];
    }
    else {
        [self.tabBarController.view  hideOrigamiTransitionWith:self.pushMenuView
                                       NumberOfFolds:foldsNum
                                            Duration:durationNum
                                           Direction:XYOrigamiDirectionFromRight
                                          completion:^(BOOL finished) {
                                              self.isShowStatus=false;
                                          }];
    }
}
//隐藏push菜单
-(void) hidePushMenu{
    if (self.isShowStatus) {
        [self swipeLeft:nil];
        self.isShowStatus=false;
    }
}


//响应右上角更多按钮
-(IBAction)popLevelAction:(id)sender{
    CustomNavigationController *navigationController=(CustomNavigationController*)[self.tabBarController.viewControllers objectAtIndex:self.tabBarController.selectedIndex];
    UIViewController *viewcontroller=[navigationController.viewControllers lastObject];
    if ( self.isShowLevelPop) {
        NSArray *param=@[@"博文荟萃",@"搜索",@"设置"];
        LeveyPopListView *lpv=[[LeveyPopListView alloc] initWithOptions:param];
        lpv.delegate=self;
        lpv.tag=HOMEPAGELPV;
        self.isShowLevelPop=false;
        [lpv showInView:viewcontroller.view animated:YES];
    }else{
        LeveyPopListView *lpv=(LeveyPopListView*)[viewcontroller.view viewWithTag:HOMEPAGELPV];
        [lpv fadeOut];
        self.isShowLevelPop=true;
    }
}

//右上角更多按钮弹出层  响应表格中选中事件
- (void)leveyRightPopListView:(LeveyPopListView *)popListView didSelectedIndex:(NSInteger)anIndex{
        CustomNavigationController *navigationController=(CustomNavigationController*)[self.tabBarController.viewControllers objectAtIndex:self.tabBarController.selectedIndex];
    switch (anIndex) {
        case 0:{
            BwhcViewController *bwhc=[[BwhcViewController alloc] initWithNibName:nil bundle:nil];
            AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
            bwhc.hidesBottomBarWhenPushed=YES;
            app.tabBarController.tabBarView.hidden=YES;
            [navigationController pushViewController:bwhc animated:YES];
            break;
        }
        case 1:{
            SearchViewController *search=[[SearchViewController alloc] initWithNibName:nil bundle:nil];
            AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
            search.hidesBottomBarWhenPushed=YES;
            app.tabBarController.tabBarView.hidden=YES;
            [navigationController pushViewController:search animated:YES];
            break;
        }
        case 2:{
            SettingViewController *setting=[[SettingViewController alloc] initWithNibName:nil bundle:nil];
            AppDelegate *app=(AppDelegate*)[[UIApplication sharedApplication] delegate];
            setting.hidesBottomBarWhenPushed=YES;
            app.tabBarController.tabBarView.hidden=YES;
            [navigationController pushViewController:setting animated:YES];
            break;
        }
    }
    self.isShowLevelPop=true;
}
//取消右上角弹出层
- (void)leveyRightPopListViewDidCancel{
    self.isShowLevelPop=true;
}

//隐藏右上角弹出层
-(void) hideRightLevelStatus{
    if (!self.isShowLevelPop) {
        [self popLevelAction:nil];
    }
}

// 在iOS6下已废弃
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return interfaceOrientation==UIInterfaceOrientationPortrait;
}


// Only on iOS6
- (BOOL)shouldAutorotate
{
    return NO;
}
// Only on iOS6
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)reloadTableViewDataSource{
     _reloading = YES;
    if (self.buttonIndex==0) {
        [self loadbowenListFromServer];
    }else{
        [self loadgonggaoListFromServer];
    }
    
    [self.mytableView reloadData];

    
    
}
- (void)doneLoadingTableViewData{
    //  model should call this when its done loading
    _reloading = NO;
    [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.mytableView];
    
    
}
#pragma mark –
#pragma mark UIScrollViewDelegate Methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    [_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
    
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    
    [_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
    
}

#pragma mark –
#pragma mark EGORefreshTableHeaderDelegate Methods
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
    
    [self reloadTableViewDataSource];
    
    
    
}
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{
    
    return _reloading; // should return if data source model is reloading
    
}
- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{
    
    return [NSDate date]; // should return date data source was last changed
    
}

-(void) dealloc{
    _pushMenuView=nil;
    _mytableView.dataSource=nil;
    _mytableView.delegate=nil;
}

@end
